package com.sl.crawler.service.crawler;

import com.sl.crawler.manager.spring.SpringContextUtils;
import com.sl.crawler.robot.CrawlerConfig;
import com.sl.crawler.robot.output.IOutput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.Map;

/**
 * Created by shiling on 2017/6/9.
 */
public class SrpingBeanCrawlerOutput implements IOutput {
    private final static Logger LOG = LoggerFactory.getLogger(SrpingBeanCrawlerOutput.class);

    private String springBeanName;

    public SrpingBeanCrawlerOutput() {
    }

    public SrpingBeanCrawlerOutput(String springBeanName) {
        this.springBeanName = springBeanName;
    }

    public String getSpringBeanName() {
        return springBeanName;
    }

    public void setSpringBeanName(String springBeanName) {
        this.springBeanName = springBeanName;
    }


    @Override
    public void output(List<Map<String, String>> list, CrawlerConfig crawlerConfig) {
        IOutput iOutput = SpringContextUtils.getBean(springBeanName, IOutput.class);
        iOutput.output(list, crawlerConfig);
    }
}
